# Declaration of variables
CC = g++

CFLAGS=-O0 -g -fPIC -fsanitize=address -Wall -Werror -IMFClinux -I../include
LIBS=-lefence -ldl -fsanitize=address

SDIR = ./
ODIR=objs
DLL = libyeux.so

_OBJS = Yeux3.o \
	CTransform/hash/lookup3.o \
	CTransform/pdiff/RGBAImage.o CTransform/pdiff/Metric.o \
	CTransform/pdiff/LPyramid.o CTransform/pdiff/CompareArgs.o \
	CTablemap/CTablemap.o CTransform/CTransform.o
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))

HEADERS =
INSTALL_DIR=../bin

# To obtain object files
$(ODIR)/%.o: $(SDIR)/%.cpp $(HEADERS)
	$(CC) -c $(CFLAGS) $< -o $@
	
# Main target
$(DLL): $(OBJS) $(OBJS_COM)
	$(CC) -o $@ $^ $(CFLAGS)  $(LIBS) -shared -fPIC  -Wl,-soname,$@.1.0.0 -o $@.1.0.0
	ln -s -f $(DLL).1.0.0 $(DLL).1.0 && \
	ln -s -f $(DLL).1.0 $(DLL).1 && \
	ln -s -f $(DLL).1 $(DLL)

install: $(DLL)
	cp $(DLL).1.0.0 $(INSTALL_DIR)
	cd $(INSTALL_DIR) && \
	rm $(DLL).1.0 $(DLL).1 $(DLL) -f &&\
	ln -s $(DLL).1.0.0 $(DLL).1.0 && \
	ln -s $(DLL).1.0 $(DLL).1 && \
	ln -s $(DLL).1 $(DLL)

distclean: clean
	cd $(INSTALL_DIR) && rm $(DLL)*

# To remove generated files
clean:
	rm -f $(DLL)* $(ODIR)/*.o $(ODIR)/*/*.o $(ODIR)/*/*/*.o *~
